package com.xxxx.web.dto;

import com.xxxx.web.entity.*;
import com.xxxx.web.enums.*;
import com.xxxx.web.tools.dto.BaseDto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;

/**
 * 出库单表类
 */
@Data
public class StockOutDto extends BaseDto {


    /**
     * 出库时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonProperty("OutTime")
    private LocalDateTime OutTime;


    /**
     * 出库状态枚举
     */
    @JsonProperty("StockOutStatus")
    private Integer StockOutStatus;


    /**
     * 货主
     */
    @JsonProperty("CustomerId")
    private Integer CustomerId;


    /**
     * 单号
     */
    @JsonProperty("No")
    private String No;


    /**
     * 仓库
     */
    @JsonProperty("WarehouseId")
    private Integer WarehouseId;


    /**
     * 计划出库时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonProperty("PlanOutTime")
    private LocalDateTime PlanOutTime;


    /**
     * 出库类型枚举
     */
    @JsonProperty("StockOutType")
    private Integer StockOutType;


    /**
     * 备注
     */
    @JsonProperty("Remark")
    private String Remark;

    @JsonProperty("WarehouseDto")
    private WarehouseDto WarehouseDto;

    @JsonProperty("CustomerDto")
    private CustomerDto CustomerDto;

    /**
     * 把出库单表传输模型转换成出库单表实体
     */
    public StockOut MapToEntity() throws InvocationTargetException, IllegalAccessException {
        StockOut StockOut = new StockOut();

        BeanUtils.copyProperties(StockOut, this);

        return StockOut;
    }

}
